package com.shujia.json;

import com.alibaba.fastjson.JSON;
import com.shujia.reflect.DataRead;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.ArrayList;

public class Demo3StudentsToJson {
    public static void main(String[] args) throws Exception {


        ArrayList<Student> students = DataRead.read("java/data/students.txt", Student.class);


        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("java/data/students.json"));

        for (Student student : students) {
            String s = JSON.toJSONString(student);

            bufferedWriter.write(s);
            bufferedWriter.newLine();
        }

        bufferedWriter.close();

    }
}
